"批量用户创建

FUNCTION ZFM_USER_CREATE.
*本地接口
**IMPORTING
**VALUE(USERNAME) LIKE BAPIBNAME-BAPIBNAME
**VALUE(LOGONDATA) LIKE BAPILOGOND STRUCTURE BAPILOGOND
**VALUE(ADDRESS) LIKE BAPIADDR3 STRUCTURE BAPIADDR3
**VALUE(PASSWORD) LIKE BAPIPWD STRUCTURE BAPIPWD
**TABLES
**RETURN STRUCTURE BAPIRET2

CALL FUNCTION 'BAPI_USER_CREATE1'
EXPORTING
USERNAME = USERNAME
LOGONDATA = LOGONDATA
PASSWORD = PASSWORD
ADDRESS = ADDRESS
TABLES
RETURN = RETURN.

READ TABLE RETURN WITH KEY TYPE = 'E'.
IF SY-SUBRC = 0.
    READ TABLE RETURN WITH KEY = 'S'.

    CALL FUNCTION 'BAPI_TRSACTION_COMMIT'.

    FNAME = 'ZFM_USER_CREATE'.
    TABNA = ''.
    ZWWXT = 'AIPTOSAP'.
    MESS-TYPE = RETURN-TYPE.
    MESS_MESSAGE = RETURN-MESSAGE.

    CALL FUNCTION 'ZFM_MM_INTERFACE_LOG'
    EXPORTING
    IM_ZFUNCM = FNAME
    IM_TBNAM = TABNA
    IM_ZWWXT = ZWWXT
    IM_MESS = MESS.

ELSE.

    CALL FUNCTION 'BAPI_TRANSCTION_ROLLBACK'.

    FNAME = 'ZFM_USER_CREATE'.
    TABNA = ''.
    ZWWXT = 'AIPTOSAP'.
    MESS-TYPE = RETURN-TYPE.
    MESS-MESSAGE = RETURN-MESSAGE.

    CALL FUNCTION 'ZFM_MM_INTERFACE_LOG'
    EXPORTING
    IM_ZFUNCM = FNAME
    IM_TBNAM = TABNA
    IM_ZWWXT = ZWWXT
    IM_MESS = MESS.
ENDIF.
ENDFUNCTION.